package com.heima.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenshan
 */
@RestController
@RequestMapping("api/v1/channel")
public class ChannelController {
    @Autowired
    private ChannelService channelService;

    /**
     * 查询所有频道信息
     * @return ResponseResult
     */
    @GetMapping("channels")
    public ResponseResult channelList() {
        return channelService.channelList();
    }

    /**
     * 频道名称模糊分页查询
     * @param channelDto 频道分页参数
     * @return ResponseResult
     */
    @PostMapping("list")
    public ResponseResult pageFindChannels(@RequestBody ChannelDto channelDto) {
        return channelService.pageFindChannels(channelDto);
    }

    /**
     * 修改频道信息
     * @param channel 频道信息
     * @return ResponseResult
     */
    @PostMapping("update")
    public ResponseResult updateChannel(@RequestBody WmChannel channel) {
        return channelService.updateChannel(channel);
    }

    /**
     * 新增频道信息
     * @param channel 频道信息
     * @return ResponseResult
     */
    @PostMapping("save")
    public ResponseResult saveChannel(@RequestBody WmChannel channel) {
        return channelService.saveChannel(channel);
    }

    /**
     * 删除频道信息
     * @param id 频道id
     * @return ResponseResult
     */
    @GetMapping("del/{id}")
    public ResponseResult delChannel(@PathVariable Integer id) {
        return channelService.delChannel(id);
    }

}
